<?php
namespace backend\controllers;

use yii\web\Controller;

/**
 * 后台基类控制器
 *
 * Class MController
 * @package backend\controllers
 */
class BaseController extends Controller
{
    /**
    * 返回数据的格式标准化
    *
    * @access public
    * @return array 返回类型
    */
    protected function returnData($data,$e = true)
    {
        if($e === true){
            return [
                'errno'=>0,
                'errmsg'=>'ok',
                'data'=>$data
            ];
        }else{
            \Yii::info(var_export($e->getMessage(),true));
            return [
                'errno'=>$e->getCode(),
                'errmsg'=>$e->getMessage(),
                'data'=>false
            ];
        }
    }
}